package com.kilon.workfaq.service.read.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kilon.workfaq.entity.PostPo;
import com.kilon.workfaq.mapper.read.PostReadMapper;
import com.kilon.workfaq.service.read.PostReadService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 博客文章表(Post)表服务实现类
 *
 * @author makejava
 * @since 2023-02-23 02:18:57
 */
@Service("postReadService")
public class PostReadServiceImpl implements PostReadService {
    @Resource
    private PostReadMapper postReadMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PostPo queryById(String id) {
        return this.postReadMapper.queryById(id);
    }

    @Override
    public List<PostPo> queryAll(PostPo post) {
        return this.postReadMapper.queryAll(post);
    }

    /**
     * 查询全部数据
     *
     * @return 实例对象
     */
    @Override
    public PageInfo<PostPo> queryAll(PostPo post, int pageCode, int pageSize) {
        PageHelper.startPage(pageCode,pageSize);
        List<PostPo> postPos = this.postReadMapper.queryAll(post);
        return new PageInfo<>(postPos);
    }
}
